<%--                                                                       --%>
<%-- Copyright (c) 2004-2005 BroadVision, Inc.  All rights reserved.       --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries. Additionally, IONA    --%>
<%-- and Orbix are trademarks of IONA Technologies, Ltd.  RSA, MD5, and    --%>
<%-- RC2 are trademarks of RSA Data Security, Inc.                         --%>
<%--                                                                       --%>

<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>

<%@ include file="/mt/file/filePickerHelper.jsp" %>

<script language="JavaScript">

// popup new window to select file
function onClickToSelectFilePopup() {
  <c:url var="url" value="/mt/filePicker.do"><c:param name="selectedContext" value="${portletAppConfigInstallForm.map.appFileRoot}"/></c:url>
  var popupUrl = "<c:out value='${url}'/>";
  var callback = "setSelectedFile";
  var folderFilter = "com.broadvision.manage.common.tools.action.file.FolderOnlyFilter";
  var fileFilter = "com.broadvision.manage.common.tools.action.file.FileOnlyFilter";
  var message = "ep.portlet.app.warfile.picker.header";
  var bundle = "ep.messages";
  filePickerPopup(popupUrl, callback, folderFilter, fileFilter, message, bundle);
}
  
// callback function
function setSelectedFile(thePath) {
  document.portletAppConfigInstallForm.portletAppPath.value = thePath;
  document.portletAppConfigInstallForm.portletAppPathSetting.value = thePath;
}

function checkRequiredFields(form) {
  if(form.portletAppPath.value == "") {
    alert('<bean:message key='ep.alert.warfile.not.selected' bundle="ep.messages"/>');
    return false;
  }
  
  if((form.location[0].checked != true) && (form.location[1].checked != true)) {
    alert('<bean:message key='ep.alert.location.not.selected' bundle="ep.messages"/>');
    return false;
  }
    
  return true;
}

function doCancel() {
  var action = '<c:url value="/ep/portletAppBrowse.do"/>';
  
  document.portletAppConfigInstallForm.action = action;
  document.portletAppConfigInstallForm.submit();
}
</script>

<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="content area">
  <tr>
    <td valign="top" width="100%">
      <div class="pageTitle">
      <c:if test="${portletAppConfigInstallForm.map.id == ''}">
        <bean:message key="ep.portlet.install.page.title" bundle="ep.messages"/>
      </c:if>
      <c:if test="${portletAppConfigInstallForm.map.id != ''}">
        <bean:message key="ep.portlet.reinstall.page.title" bundle="ep.messages" arg0="${portletAppConfigInstallForm.map.id}"/>
      </c:if>
      </div>
      <div class="errorMessage"><html:errors bundle="ep.messages"/></div>
      <%@ include file="/mc/common/pagetab.jsp" %>

      <!- place body here -->

      <html-el:form action="/ep/portletAppConfigInstall.do" onsubmit="return checkRequiredFields(this);">

      <html-el:hidden property="portletAppId" value="${portletAppConfigInstallForm.map.id}"/>
      <html-el:hidden property="serverId" value="${portletAppConfigInstallForm.map.serverId}"/>
      <html-el:hidden property="portletAppPathSetting" value="${portletAppConfigInstallForm.map.portletAppPath}"/>
      <html-el:hidden property="portletappaction" value="${portletAppConfigInstallForm.map.portletappaction}"/>
      
      <input type="hidden" name="forward" value="<c:out value="${epActionForward.map.forward}"/>">

      <div class="pageSubtitle">
        <span class="left"><bean:message key="ep.portlet.app.configuration" bundle="ep.messages"/></span>
        <span class="right">&nbsp;</span>
      </div>

      <table class="labelForm" width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td class="label"><bean:message key="ep.portlet.app.path" bundle="ep.messages"/>*:</td>
        <td class="labelField"><html-el:text property="portletAppPath" size="50" maxlength="80" disabled="true"/><input type="button" class="inputButton" value="<bean:message key="button.choose.portlet.app.warfile" bundle="ep.messages"/>" onclick="onClickToSelectFilePopup();">
        </td>
      </tr>

      <tr>
        <td class="label"><bean:message key="ep.portlet.app.location" bundle="ep.messages"/>*:</td>
        <td class="labelField"><html-el:radio property="location" value="local"/><bean:message key="ep.portlet.app.location.local" bundle="ep.messages"/>&nbsp;<html-el:radio property="location" value="remote"/><bean:message key="ep.portlet.app.location.remote" bundle="ep.messages"/>
        </td>
      </tr>

      </table>

      <div class="pageButtonWrap" align="right">
        <input type="reset" name="resetBtn" value="<bean:message key='button.reset' bundle="ep.messages"/>" class="inputButton">
        &nbsp;&nbsp;
        <input type="button" name="cancelData" class="inputButton" value="<bean:message key='button.cancel' bundle="ep.messages"/>" onclick="doCancel()">
        <input type="submit" name="nextData" class="inputButton" value="<bean:message key='button.next' bundle="ep.messages"/>">
      </div>
      </html-el:form>

    </td>
  </tr>
</table>
